home *** CD-ROM | disk | FTP | other *** search
- #!/bin/sh
- # $Id: index-mon2num,v 1.1 1992/08/09 16:36:25 cross Exp cross $
-
- awk '
- BEGIN {
- months[1] = "Jan"; months[2] = "Feb"; months[3] = "Mar";
- months[4] = "Apr"; months[5] = "May"; months[6] = "Jun";
- months[7] = "Jul"; months[8] = "Aug"; months[9] = "Sep";
- months[10] = "Oct"; months[11] = "Nov"; months[12] = "Dec";
- }
- /^#VERSION/ {
- if ($2 != "1.0") {
- print "wrong version header \"" $2 "\". cannot decode format.";
- exit;
- }
- off=3;
- while(substr($0,off,1) == " " || substr($0,off,1) == " ")
- off++;
- while(substr($0,off,1) != " " && substr($0,off,1) != " ")
- off++;
-
- printf("#VERSION (num-month)1.0%s\n", substr($0,off,2048));
- version=1;
- next;
- }
- /^F/ || /^D/ || /^L/ {
- if (!version) {
- print "no version (#VERSION) header provided. cannot decode format.";
- exit;
- }
- if (NF < 5) {
- print "illegal format in line " NR;
- exit;
- }
- # must be seeked from left because of embedded spaces in filenames!
- off=0;
- for(i = 0; i < 2; i++) {
- while(substr($0,off,1) != " " && substr($0,off,1) != " ")
- off++;
- while(substr($0,off,1) == " " || substr($0,off,1) == " ")
- off++;
- }
- off += 3;
- monthstr=substr($0,off,3);
-
- for(month = 12; month > 0; month--)
- if ( months[month] == monthstr) break;
-
- if (month <= 0) {
- print "illegal month name " monthstr " in line " NR;
- exit;
- }
-
- printf("%s%02d%s\n", substr($0,1,off-1), month, substr($0,off+3,4096));
- next;
- }
- {
- # comment lines
- print $0;
- }
- '
-